package com.zengqingfa.thread.demo3;

/**
 * @fileName: ThreadTest1
 * @author: zengqf3
 * @date: 2020-10-7 11:51
 * @description:
 */
public class SleepThread implements Runnable {

    private int tickets = 10;

    @Override
    public void run() {
        while (true) {
            if (tickets <= 0) {
                break;
            }
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "-->拿到了第" + tickets-- + "票");
        }
    }

    public static void main(String[] args) {
        SleepThread test1 = new SleepThread();
        for (int i = 0; i < 3; i++) {
            new Thread(test1, "thread-" + i).start();
        }
    }
}
